<?php
namespace app\user\validate;
use think\Validate;
class User extends Validate {
    //验证字段
    protected $rule = [
        'openid' => ['require'],
        'avatarUrl' => ['require'],
        'nickName' => ['require'],
        'gender' => ['require','number'],
        'country' => ['require'],
        'city' => ['require'],
        'province' => ['require'],
        'language' => ['require'],
        'merchantID' => ['require','number'],
        'createTime' => ['require','number'],
        'status' => ['require','number'],
        'phone' => ['require'],
        'id' => ['require','number'],
    ];
    //返回消息
    protected $message = [
        'openid.require' => 'openID必须',
        'avatarUrl.require' => '头像必须',
        'nickName.require' => '昵称必须',
        'gender.require' => '性别必须',
        'gender.number' => '性别不是数字',
        'country.require' => '国家必须',
        'city.require' => '城市必须',
        'province.require' => '省份必须',
        'language.require' => '语言必须',
        'merchantID.require' => '商家ID必须',
        'merchantID.number' => '商家ID不是数字',
        'createTime.require' => '创建时间必须',
        'createTime.number' => '创建时间不是数字',
        'status.require' => '状态必须',
        'status.number' => '状态不是数字',
        'phone.require' => '电话必须',
        'id.require' => 'id必须',
        'id.number' => 'id不是数字',
    ];

    // except_id 场景
    public function sceneExcept_id(){
        return $this->only(['openid','avatarUrl','nickName','gender','country','city','province','language','merchantID','createTime','status','phone']);
    }

    // only_id 场景
    public function sceneOnly_id(){
        return $this->only(['id']);
    }

    // all_field 场景
    public function sceneAll_field(){
        return $this->only(['id','openid','avatarUrl','nickName','gender','country','city','province','language','merchantID','createTime','status','phone']);
    }
}
